//
//  WPPopView.m
//  LikeAlertView
//
//  Created by rimi on 15/8/21.
//  Copyright (c) 2015年 魏攀. All rights reserved.
//

#import "WPPopView.h"
#define SCREEN_W CGRectGetWidth([[UIScreen mainScreen]bounds])
#define SCREEN_H CGRectGetHeight([UIScreen mainScreen].bounds)

@interface WPPopView ()
-(void)initInterface;

@end

@implementation WPPopView {
    UIWindow * _popWindow;
}
- (instancetype)init {
    self = [super init];
    if (self) {
        [self initInterface];
    }
    return self;
}
- (void)initInterface {
    _popWindow = [[UIWindow alloc]initWithFrame:[UIScreen  mainScreen].bounds];
    _popWindow.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.5];
    _popWindow.windowLevel = UIWindowLevelAlert;
    self.frame = CGRectMake(0, 0, SCREEN_W*0.75, SCREEN_H*0.7);
    self.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];
    self.center = _popWindow.center;
    self.layer.cornerRadius = 5;
    self.clipsToBounds = YES;
    [_popWindow addSubview:self];
}
- (void)show {
    [_popWindow makeKeyAndVisible];
}
- (void)hide {
    _popWindow.windowLevel = UIWindowLevelNormal;
    [self removeFromSuperview];
    [_popWindow resignKeyWindow];
    _popWindow.alpha = 0;
}
@end
